<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
	<style type="text/css">
		.dog{
			margin-left: 10px;
			float: left;
		}
		.man{
			float: right;
			margin-right: 10px;
			display: none;
		}
	
	</style>
	<script type="text/javascript">
		num = 0;
		function ff(){

			var dog=document.getElementById('dog');
			var man=document.getElementById('man');
			 dogtime=setInterval(fundog,500)
			function fundog(){
				var left= parseInt(window.getComputedStyle ? window.getComputedStyle(dog,null).marginLeft : dog.currentStyle.marginLeft);
			
				if (left<=1200) {
					dog.style.marginLeft=left+150+"px";
				}

				else {
					dog.style.display='none';
					man.style.display='block';
					clearInterval(dogtime);
					 mantime=setInterval(funman,500);
				}
			}
		
			function funman(){
				var right= parseInt(window.getComputedStyle ? window.getComputedStyle(man,null).marginRight : man.currentStyle.marginRight);
				if (right<=1200) {
					man.style.marginRight=right+150+"px";
				}

				else {
					man.style.display='none';
					man.style.marginRight=10+"px";
					dog.style.display='block';
					dog.style.marginLeft=10+"px";
					clearInterval(mantime);
					ff();
					
				}
			}	


		}
		function start(){
			if(num==0){
				ff();
				num=1;
			}
			
		}

		function stop(){
					num=0;
					clearInterval(dogtime);
					clearInterval(mantime);
				}

			
	</script>
</head>
<body>
	<input id="start" type="button" value="开始" onclick="start()">
	<input id="stop" type="button" value="停止" onclick="stop()">
	<br>
	<br>
	<div class="dog" id="dog"><img src="images/13.gif" alt=""></div>
	<div class="man" id="man"><img src="images/14.gif" alt=""></div>
</body>
</html>